home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Excel / Sheet.jar / sheet / CellResize.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-03  |  1.5 KB  |  73 lines

  1. package sheet;
  2.  
  3. import javax.microedition.lcdui.Canvas;
  4. import javax.microedition.lcdui.Graphics;
  5.  
  6. final class CellResize extends Canvas {
  7.    private Table data;
  8.    private int appWidth;
  9.    private int appHeight;
  10.    private int curCol;
  11.    private int curRow;
  12.    private short curWid;
  13.    private short curHei;
  14.    private Backable winBack;
  15.  
  16.    public CellResize(Table var1, Backable var2) {
  17.       this.data = var1;
  18.       this.winBack = var2;
  19.       this.appWidth = ((Canvas)this).getWidth();
  20.       this.appHeight = ((Canvas)this).getHeight();
  21.       this.curCol = this.data.getCurrentColumn();
  22.       this.curRow = this.data.getCurrentRow();
  23.       this.curWid = this.data.getColumnWidth(this.curCol);
  24.       this.curHei = this.data.getRowHeight(this.curRow);
  25.    }
  26.  
  27.    protected void paint(Graphics var1) {
  28.       var1.setColor(16777215);
  29.       var1.fillRect(0, 0, this.appWidth, this.appHeight);
  30.       this.data.paint(var1, this.appWidth, this.appHeight, 1);
  31.    }
  32.  
  33.    protected void keyPressed(int var1) {
  34.       int var2 = ((Canvas)this).getGameAction(var1);
  35.       switch (var2) {
  36.          case 1:
  37.             if (this.curHei > 1) {
  38.                --this.curHei;
  39.                this.data.setRowHeight(this.curRow, this.curHei);
  40.             }
  41.             break;
  42.          case 2:
  43.             if (this.curWid > 1) {
  44.                --this.curWid;
  45.                this.data.setColumnWidth(this.curCol, this.curWid);
  46.             }
  47.             break;
  48.          case 3:
  49.          case 4:
  50.          case 7:
  51.          default:
  52.             if (var1 == -12) {
  53.                this.winBack.show();
  54.                return;
  55.             }
  56.             break;
  57.          case 5:
  58.             ++this.curWid;
  59.             this.data.setColumnWidth(this.curCol, this.curWid);
  60.             break;
  61.          case 6:
  62.             ++this.curHei;
  63.             this.data.setRowHeight(this.curRow, this.curHei);
  64.             break;
  65.          case 8:
  66.             this.winBack.show();
  67.             return;
  68.       }
  69.  
  70.       ((Canvas)this).repaint();
  71.    }
  72. }
  73.